"""

"""


class user:
    __age = 18

    def __init__(self, age, username):
        self.__age = age
        self.username = username

    def __str__(self):
        return self.username + ":" + str(self.__age)

    # 定义公有的set和get方法
    def getAge(self):
        return self.__age

    def setAge(self, age):
        self.__age = age

    # 暴露age私有属性，和上面的get方法一样，然后对象就可以通过object.age访问该私有属性了
    @property
    def age(self):
        return self.__age

    # 设置属性，相当于上面的setAge方法,必须要先有上面的@property，先有get再有set
    @age.setter
    def age(self, age):
        self.__age = age


u = user(20, "高嘉银")
print(u)
print(dir(u))  # 除了私有的属性和方法都会显示出来
print(u.age)
u.age = 30
print(u.age)
